﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
using System.Text;

public partial class Agency_LimitPriceChildren : System.Web.UI.Page, HZ.MBSM.BLL.IPageDescribe
{
    
     string projectid;

    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (HZ.MBSM.BLL.Login.CheckAssert(UseAccountType))
        {
            if (!IsPostBack)
            {
                ProjectBandin();
            }
            projectid = listProject.SelectedValue;
            fctConditions();
            showGridView();
        }
    }
    private void ProjectBandin()
    {
        Db db = new Db();
        string strSql = "select projectid,ProjectMarker,Title from project order by projectid desc";
        System.Data.IDataReader dr = db.DataReader(strSql);
        listProject.DataSource = dr;
        listProject.DataTextField = "Title";
        listProject.DataValueField = "projectid";
        listProject.DataBind();
        dr.Close();
        dr.Dispose();
         projectid = listProject.SelectedValue;
    }
  
   
    public void showGridView()
    {

        string strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "LPNew";                                               //要查询的表明
        dbPage.SelectFieldGroup = "ProductCode,Bidtablename,bidtabletype,bidtableoutlookc,convert(numeric(20,4),LimitPrice),QualityLevels,memo4";
        dbPage.Key = "ProductCode,convert(numeric(20,4),LimitPrice) as LimitPrice,QualityLevels";//表的主键    
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.SelectField = "ProductCode,Bidtablename,bidtabletype,bidtableoutlookc,convert(numeric(20,4),LimitPrice) as LimitPrice,QualityLevels,memo4";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 30;                                                    //没有显示记录条数   
        dbPage.OrderBy = "ProductCode,QualityLevels";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReaderGroup(60);
        GridView1.DataSource = dr;
        GridView1.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键
    }
    public string fctConditions()
    {
        string _strWhere = "ProjectId=" + projectid;
        //品目号
        string _strProductCode = txtProductCode.Text.Trim();
        if (_strProductCode != "")
        {
            _strWhere += " And ProductCode like '%" + _strProductCode + "%' ";
        }
        //质量层次
        string _strQualityLevels = lstQualityLevels.SelectedItem.Text;
        if (_strQualityLevels != "全部")
        {
                _strWhere += " And  QualityLevels like '%" + _strQualityLevels + "%' ";
        }
        //招标通用名
        string _strBidtableName = txtBidtableName.Text.Trim();
        if (_strBidtableName != "")
        {
            _strWhere += " And  BidtableName like '%" + _strBidtableName + "%' ";
        }
        //招标剂型
        string _strBidtableType = txtBidtableType.Text.Trim();
        if (_strBidtableType != "")
        {
            _strWhere += "  And  BidtableType like '%" + _strBidtableType + "%' ";
        }
        //招标规格
        string _strBidtableOutlookc = txtBidtableOutlookc.Text.Trim();
        if (_strBidtableOutlookc != "")
        {
            _strWhere += "  And  BidtableOutlookc like '%" + _strBidtableOutlookc + "%' ";
        }
        return _strWhere;
     
    }

    #region IPageDescribe 成员


    public string Describe
    {
        get { return "限价查看"; }
    }
    public string Name
    {
        get { return "限价查看"; }
    }
    public string ParentName
    {
        get { return "限价查看"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumBidGoods);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumSupervise);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
            return _AccountType;
        }
    }

    #endregion


   
}
